/**
 * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package org.ossr.portlets.pm.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.impl.BaseModelImpl;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.Date;

/**
 * @author Edgar Zavala
 */
public class PrivateMessageClp extends BaseModelImpl<PrivateMessage>
	implements PrivateMessage {
	public PrivateMessageClp() {
	}

	public long getPrimaryKey() {
		return _messageId;
	}

	public void setPrimaryKey(long pk) {
		setMessageId(pk);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_messageId);
	}

	public long getMessageId() {
		return _messageId;
	}

	public void setMessageId(long messageId) {
		_messageId = messageId;
	}

	public long getOwnerId() {
		return _ownerId;
	}

	public void setOwnerId(long ownerId) {
		_ownerId = ownerId;
	}

	public String getRecepients() {
		return _recepients;
	}

	public void setRecepients(String recepients) {
		_recepients = recepients;
	}

	public Date getCreationDate() {
		return _creationDate;
	}

	public void setCreationDate(Date creationDate) {
		_creationDate = creationDate;
	}

	public boolean getIsReply() {
		return _isReply;
	}

	public boolean isIsReply() {
		return _isReply;
	}

	public void setIsReply(boolean isReply) {
		_isReply = isReply;
	}

	public Date getReplyDate() {
		return _replyDate;
	}

	public void setReplyDate(Date replyDate) {
		_replyDate = replyDate;
	}

	public boolean getDeleted() {
		return _deleted;
	}

	public boolean isDeleted() {
		return _deleted;
	}

	public void setDeleted(boolean deleted) {
		_deleted = deleted;
	}

	public boolean getReaded() {
		return _readed;
	}

	public boolean isReaded() {
		return _readed;
	}

	public void setReaded(boolean readed) {
		_readed = readed;
	}

	public String getSubject() {
		return _subject;
	}

	public void setSubject(String subject) {
		_subject = subject;
	}

	public String getBody() {
		return _body;
	}

	public void setBody(String body) {
		_body = body;
	}

	public PrivateMessage toEscapedModel() {
		if (isEscapedModel()) {
			return this;
		}
		else {
			return (PrivateMessage)Proxy.newProxyInstance(PrivateMessage.class.getClassLoader(),
				new Class[] { PrivateMessage.class },
				new AutoEscapeBeanHandler(this));
		}
	}

	public Object clone() {
		PrivateMessageClp clone = new PrivateMessageClp();

		clone.setMessageId(getMessageId());
		clone.setOwnerId(getOwnerId());
		clone.setRecepients(getRecepients());
		clone.setCreationDate(getCreationDate());
		clone.setIsReply(getIsReply());
		clone.setReplyDate(getReplyDate());
		clone.setDeleted(getDeleted());
		clone.setReaded(getReaded());
		clone.setSubject(getSubject());
		clone.setBody(getBody());

		return clone;
	}

	public int compareTo(PrivateMessage privateMessage) {
		int value = 0;

		value = DateUtil.compareTo(getCreationDate(),
				privateMessage.getCreationDate());

		if (value != 0) {
			return value;
		}

		return 0;
	}

	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		PrivateMessageClp privateMessage = null;

		try {
			privateMessage = (PrivateMessageClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long pk = privateMessage.getPrimaryKey();

		if (getPrimaryKey() == pk) {
			return true;
		}
		else {
			return false;
		}
	}

	public int hashCode() {
		return (int)getPrimaryKey();
	}

	public String toString() {
		StringBundler sb = new StringBundler(21);

		sb.append("{messageId=");
		sb.append(getMessageId());
		sb.append(", ownerId=");
		sb.append(getOwnerId());
		sb.append(", recepients=");
		sb.append(getRecepients());
		sb.append(", creationDate=");
		sb.append(getCreationDate());
		sb.append(", isReply=");
		sb.append(getIsReply());
		sb.append(", replyDate=");
		sb.append(getReplyDate());
		sb.append(", deleted=");
		sb.append(getDeleted());
		sb.append(", readed=");
		sb.append(getReaded());
		sb.append(", subject=");
		sb.append(getSubject());
		sb.append(", body=");
		sb.append(getBody());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(34);

		sb.append("<model><model-name>");
		sb.append("org.ossr.portlets.pm.model.PrivateMessage");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>messageId</column-name><column-value><![CDATA[");
		sb.append(getMessageId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>ownerId</column-name><column-value><![CDATA[");
		sb.append(getOwnerId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>recepients</column-name><column-value><![CDATA[");
		sb.append(getRecepients());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>creationDate</column-name><column-value><![CDATA[");
		sb.append(getCreationDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>isReply</column-name><column-value><![CDATA[");
		sb.append(getIsReply());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>replyDate</column-name><column-value><![CDATA[");
		sb.append(getReplyDate());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>deleted</column-name><column-value><![CDATA[");
		sb.append(getDeleted());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>readed</column-name><column-value><![CDATA[");
		sb.append(getReaded());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>subject</column-name><column-value><![CDATA[");
		sb.append(getSubject());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>body</column-name><column-value><![CDATA[");
		sb.append(getBody());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private long _messageId;
	private long _ownerId;
	private String _recepients;
	private Date _creationDate;
	private boolean _isReply;
	private Date _replyDate;
	private boolean _deleted;
	private boolean _readed;
	private String _subject;
	private String _body;
}